package com.ytjj.qmyx.admin.controller;

import com.ytjj.common.utils.TokenUtil;
import com.ytjj.common.utils.feishu.FeiShuUtil;
import com.ytjj.qmyx.mall.mapper.ProductReviewsMapper;
import com.ytjj.qmyx.mall.model.ProductReviews;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.http.server.ServerHttpRequest;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 *
 * @version 1.0
 *
 */
@RefreshScope
@RestController
@RequestMapping("/test")
public class TestController {
    @Resource
    private ProductReviewsMapper productReviewsMapper;


    @GetMapping("/sendFeishu")
    public String sendFeishu() {
        FeiShuUtil.sendMsg("test admin");
        return "ok";
    }

    @GetMapping("/check")
    public String check() {
        return "ok";
    }


    @PostMapping("/addProductReviews")
    public String addProductReviews(@RequestBody List<ProductReviews> productReviews) {
        for (ProductReviews productReview : productReviews) {
            ProductReviews newEntity = new ProductReviews();
            newEntity.setContent(productReview.getContent());
            newEntity.setHeadImg(productReview.getHeadImg());
            newEntity.setNickname(productReview.getNickname());
            productReviewsMapper.insertSelective(newEntity);
        }
        return "ok";
    }
}
